package thread.states;

import org.testng.annotations.Test;
import util.MathUtil;

/**
 * @author
 */
public class BaseState {

    public static void main(String[] args) {

        Runnable r = () -> {
            for (int i = 0; i < 50; i++) {
                MathUtil.resolvePrime(987654321098765432L);
                System.out.println(i);

                // 不会执行，
                if (i == 18 && !Thread.interrupted()) {

                    System.out.println("thread stop");
                }
            }



        };

        Thread t1 = new Thread(r);
        t1.start();

        System.out.println("execute interrupt");
        // 调用中断方法并不会让线程停止运行
        t1.interrupt();

    }



    @Test
    private void t1() {
        Runnable r = () -> {
            for (int i = 0; i < 50; i++) {
                MathUtil.resolvePrime(987654321098765432L);
                System.out.println(i);
            }

        };

        Thread t1 = new Thread(r);
        t1.start();

//        t1.interrupt();
    }




}
